#include <vector>
#include <iostream>
using namespace std;

class Solution
{
private:
    vector<vector<int>> res;
    vector<int> path; //回溯路径
protected:
    void backTracking(vector<int> &nums, int startIndex)
    {
        res.push_back(path);
        if (startIndex >= nums.size())
            return;
        for (int i = startIndex; i < nums.size(); i++)
        {
            path.push_back(nums[i]); //试探一步
            backTracking(nums, i + 1);
            path.pop_back(); //撤回修改
        }
    }

public:
    vector<vector<int>> subsets(vector<int> &nums)
    {
        res.clear();
        path.clear();
        backTracking(nums, 0);
        return res;
    }
};